package xdpm.nhom16.DAO;

import xdpm.nhom16.DTO.TuKhoaDuongDTO;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class TuKhoaDuongDAO extends AbstractTuKhoaDAO<TuKhoaDuongDTO> {

	protected static final String COLUMN_PARENT = "MaDuong";
	protected static final String COLUMN_TUKHOA = "TuKhoaDuong";
	protected static final String COLUMN_ID = "MaTuKhoaDuong";
	protected static final String[] COLUMNS_NAME = new String[] { COLUMN_ID, COLUMN_TUKHOA, COLUMN_PARENT };
	protected static final String TABLE_NAME = "TUKHOADUONG";

	public TuKhoaDuongDAO(SQLiteDatabase db) {
		super(db);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected String getTableName() {

		return TABLE_NAME;
	}

	@Override
	protected String getNameColumnId() {
		return COLUMN_ID;
	}

	@Override
	protected String[] getNameColumns() {
		return COLUMNS_NAME;
	}

	@Override
	protected TuKhoaDuongDTO cusorToDTO(Cursor cursor) {
		int id = cursor.getInt(0);
		TuKhoaDuongDTO dto = new TuKhoaDuongDTO();
		dto.setMaTuKhoaDuong(id);
		if (!cursor.isNull(1))
			dto.setTuKhoaDuong(cursor.getString(1));
		if (!cursor.isNull(2))
			dto.setMaDuong(cursor.getInt(2));
		return dto;
	}

	@Override
	protected String getNameColumnTuKhoa() {
		return COLUMN_TUKHOA;
	}

	@Override
	protected String getNameColumnRefIdParent() {
		// TODO Auto-generated method stub
		return COLUMN_PARENT;
	}
}
